#include <stdio.h>

int main0()
{
    int a[] = {0,1,2,3,4,5,6,7,8,9};
    //short a[10] = {0,1,2,3,4,5,6,7,8,9};
    int i;
    for(i = 0; i < (int)sizeof(a) / (int)sizeof(a[0]); i++)
    {
        printf("a[%d] = %d\n", i, a[i]);
    }
    
    printf("%lu, %lu\n", sizeof(a), sizeof(a[0]));
    return 0;
}

int main1()
{
    // 考虑周全，负数不好处理，这是目前最佳方案
    int i;
    int a[] = {32,321312213,3123,12312,3123,123,123,12,3};
    int num = a[0];
    for(i = 1; i< (int)sizeof(a) / (int)sizeof(a[0]); i++)
    {
        if (a[i] > num)
        {
            num = a[i];
        }
    }
    printf("%d\n", num);
}



int main()
{
    int i;
    int a[] = {-32,-321312213,3123,-12312,-3123,-123,-123,12,3};
    int tmp = a[0];
    for(i = 1; i < (int)sizeof(a) / (int)sizeof(a[0]); i++)// 最大成员
    {
        if (a[i] > tmp)
            tmp = a[i];
    }
    printf("max = %d\n", tmp);


    // 第二大成员
    int max = 0;//最大成员
    int smax = 0;//第二大成员
    //if (a[0] > a[1]) ? (max = a[0], smax = a[1]):(max = a[1], smax = a[0]); 
    /*
    if (a[0] > a[1])
    {
        max = a[0];
        smax = a[1];
    }
    else
    {
        max = a[1];
        smax = a[0];
    }
    */

    smax = a[0]>a[1] ? a[0]:a[1];
    max = a[0]>a[1] ? a[1]:a[0];


    for(i = 2; i < (int)sizeof(a) / (int)sizeof(a[0]); i++)
    {
        if (a[i] > max)
        {
            smax = max;
            max = a[i];
        }
        else if (a[i] < max && a[i] > smax)
        {
            smax = a[i];
        }
    }

    printf("max = %d\n", max);
    printf("smax = %d\n", smax);




    return 0;
}
